package com.itheima.activiti.controller.system;

import com.itheima.activiti.common.R;
import com.itheima.activiti.dto.system.OrgUserTreeDTO;
import com.itheima.activiti.dto.system.UserDTO;
import com.itheima.activiti.service.system.UserService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@Slf4j
@RestController
@RequestMapping("/user")
@Api(tags = "用户接口")
public class UserController {

    @Autowired
    private UserService userService;

    @ApiOperation("查询用户树")
    @GetMapping(value = "/tree")
    public R<List<OrgUserTreeDTO>> tree() {
        List<OrgUserTreeDTO> orgUserTreeDTOS = userService.tree();
        return R.success(orgUserTreeDTOS);
    }

    @ApiOperation("查询全部用户")
    @GetMapping(value = "/list")
    public R<List<UserDTO>> list() {
        List<UserDTO> users = userService.list();
        return R.success(users);
    }
}
